#pragma once

#ifdef WGLENGINE_DLL
#define WGLENGINE_EXPORT __declspec(dllexport)
#else
#define WGLENGINE_EXPORT __declspec(dllimport)
#endif

#include "GL\glew.h"
#include <vector>

class WGLENGINE_EXPORT RenderTexture
{
public:
	enum DepthState {None, DepthBuffer, DepthTexture};

protected:
	GLuint fbo;
	GLuint depthTex;
	GLuint* targets;					//!< targets linked to the fbo
	GLenum* formats;					//!< formats for all the targets
	GLenum* types;						//!< types for all the targets
	GLenum* textureTypes;
	
	int numOfTargets; 
	int targetWidth;
	int targetHeight;
	DepthState depthState;

	void InitFBO();
	virtual void InitRenderTextures();
	void InitDepthTexture();
	void InitDepthBuffer();
	
public:
	RenderTexture();
	virtual ~RenderTexture();

	//allow to specify types, formats, internalFormats for each target of the fbo
	virtual bool Init(int targetCount, int width, int height, DepthState depthState = None, GLenum* textureType = nullptr, GLenum* formats = nullptr, GLenum* types = nullptr);
	GLuint GetTextureID(int targetIndex = 0);

	void Bind();
	void Unbind();
};